package com.yyk.yiliao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.yyk.yiliao.R;

import java.util.List;

/**
 * Created by ${zk} on 2018/8/21 0021.
 * <p>
 * 商品详情评价中的
 */

public class Detail_F_Three_Fragment extends BaseAdapter {
    private List<Integer>  list;
    private LayoutInflater inflater;
    private Context        context;


    public Detail_F_Three_Fragment(Context context, List<Integer> list) {
        this.list = list;
        this.context = context;

        inflater = LayoutInflater.from(context);
    }

    /**
     * 先判断数据集的大小是否足够显示满本页？listData.size() > (mIndex + img1)*mPagerSize
     * 如果满足，则此页就显示最大数量mPagerSize的个数
     * 如果不够显示每页的最大数量，那么剩下几个就显示几个 (listData.size() - mIndex*mPagerSize)
     */
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_gridview_pinglunzp, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.img.setImageResource(list.get(position));
        return convertView;
    }

    private class ViewHolder {
        private ImageView img;

        public ViewHolder(View item) {
            img = item.findViewById(R.id.img);

        }
    }
}
